Decatography algorithm